var t = require("../../../../@babel/runtime/helpers/interopRequireDefault"), e = t(require("../../../../utils/util.js")), o = t(require("../../../../utils/dateutils.js")), a = getApp();

Page({
    data: {
        endorsement_name: "",
        params_json: [],
        onetap: !0,
        twotap: !0,
        date: new Date().getTime(),
        isShowPicker: !1,
        isShowPicker_two: !1,
        form: {
            market_price: "",
            mini_markup: "",
            prepayment_mode: "1",
            advance_proportion: "",
            advance_money: "",
            start_shooting: "",
            end_shooting: "",
            duration: "",
            endorsement: "",
            start_price: "",
            is_restart: "0",
            em_proportion: "",
            em_mode: "1",
            fixed_price: "",
            delay_before_minute: "",
            delay_cycle_minute: ""
        },
        show: !1
    },
    onLoad: function(t) {
        if (t.json) {
            var e = JSON.parse(t.json);
            this.setData({
                params_json: e
            });
        }
        t.goods_id && (this.setData({
            goods_id: t.goods_id
        }), this.getInfo()), this.getAgreement(), console.log(this.data.params_json);
    },
    back: function() {
        wx.navigateBack({
            delta: 2
        });
    },
    onYMDhms: function(t) {
        this.setData({
            isShowPicker: !0,
            mode: "YMDhm",
            data: {
                type: "YMDhm"
            }
        });
    },
    onYMDhms_two: function(t) {
        this.setData({
            isShowPicker_two: !0,
            mode: "YMDhm",
            data: {
                type: "YMDhm"
            }
        });
    },
    datePickerCancellEvent: function(t) {
        this.setData({
            isShowPicker: !1,
            isShowPicker_two: !1
        });
    },
    datePickerOkEvent: function(t) {
        var e = t.detail.date, a = o.default.formatLongTime(e, "Y/M/D h:m");
        this.setData({
            isShowPicker: !1,
            "form.start_shooting": o.default.formatLongTime(e, "Y/M/D h:m"),
            isshowtime1: a
        }), console.log(Date.parse(this.data.form.start_shooting));
    },
    datePickerOkEvent_two: function(t) {
        console.log(Date.parse(this.data.form.start_shooting));
        var e = Date.parse(new Date()), a = t.detail.date, i = Date.parse(this.data.form.start_shooting), n = Date.parse(o.default.formatLongTime(a, "Y/M/D h:m")), s = o.default.formatLongTime(a, "Y/M/D h:m");
        console.log("------------------------", n, e), Number(i) >= Number(n) ? wx.showToast({
            title: "结束时间要大于开始时间",
            icon: "none",
            duration: 1e3
        }) : this.setData({
            isShowPicker_two: !1,
            "form.end_shooting": o.default.formatLongTime(a, "Y/M/D h:m"),
            isshowtime2: s
        });
    },
    lastStep: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    is_onetap: function() {
        this.setData({
            onetap: !this.data.onetap
        });
    },
    is_twotap: function() {
        this.setData({
            twotap: !this.data.twotap
        });
    },
    line1: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.market_price": e
        });
    },
    line2: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.start_price": e
        });
    },
    line3: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.fixed_price": e
        });
    },
    line4: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.mini_markup": e
        });
    },
    line5: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.mini_deal": e
        });
    },
    line6: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.time_interval": e
        });
    },
    line7: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.duration": e
        });
    },
    line8: function(t) {
        var e = t.detail.value, o = t.currentTarget.dataset.id;
        console.log(o, e), "1" == o ? this.setData({
            "form.prepayment_mode": o,
            "form.advance_proportion": e
        }) : "2" == o && this.setData({
            "form.prepayment_mode": o,
            "form.advance_money": e
        }), console.log(this.data.form.prepayment_mode, this.data.form.advance_proportion);
    },
    line9: function(t) {
        var e = t.detail.value, o = t.currentTarget.dataset.id;
        console.log(o, e), "1" == o ? this.setData({
            "form.em_mode": o,
            "form.em_proportion": e
        }) : "2" == o && this.setData({
            "form.em_mode": o,
            "form.endorsement": e
        });
    },
    tap_delay_before_minute: function(t) {
        var e = t.detail.value;
        "delay" == t.currentTarget.dataset.key ? this.setData({
            "form.delay_before_minute": e
        }) : this.setData({
            "form.delay_cycle_minute": e
        });
    },
    line10: function(t) {
        var e = t.detail.value;
        this.setData({
            "form.dispatch_price": e
        });
    },
    eInvoiceChange: function(t) {
        var e = t.detail;
        this.setData({
            "form.is_restart": e
        });
    },
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getAgreement: function() {
        var t = this, e = a.getNetAddresss("plugin.auction.api.index.getAuctionData");
        a._getNetWork({
            url: e,
            success: function(e) {
                var o = e.data;
                1 == o.result ? t.setData({
                    is_examine: o.data.getAgreement.is_examine,
                    endorsement_name: o.data.endorsement_name
                }) : wx.showToast({
                    title: o.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getInfo: function() {
        var t = this;
        console.log(this.data.goods_id);
        var o = {
            art: "editGoods",
            goods_id: this.data.goods_id
        }, i = a.getNetAddresss("plugin.auction.api.index.getAuctionData");
        a._postNetWork({
            url: i,
            data: o,
            success: function(o) {
                var i = o.data;
                1 == i.result ? (console.log(i), t.setData({
                    "form.advance_money": i.data.editGoods.has_one_auction_goods.advance_money,
                    "form.advance_proportion": i.data.editGoods.has_one_auction_goods.advance_proportion,
                    "form.market_price": i.data.editGoods.market_price,
                    "form.endorsement": i.data.editGoods.has_one_auction_goods.endorsement,
                    "form.em_proportion": i.data.editGoods.has_one_auction_goods.em_proportion,
                    "form.mini_markup": i.data.editGoods.has_one_auction_goods.mini_markup,
                    "form.start_price": i.data.editGoods.has_one_auction_goods.start_price,
                    "form.start_shooting": e.default.formatTimeTwo(i.data.editGoods.has_one_auction_goods.start_shooting, "Y/M/D h:m:s"),
                    "form.end_shooting": e.default.formatTimeTwo(i.data.editGoods.has_one_auction_goods.end_shooting, "Y/M/D h:m:s"),
                    "form.fixed_price": i.data.editGoods.has_one_auction_goods.fixed_price,
                    "form.duration": i.data.editGoods.has_one_auction_goods.duration,
                    "form.time_interval": i.data.editGoods.has_one_auction_goods.time_interval,
                    twotap: !!a._isTextEmpty(i.data.editGoods.has_one_auction_goods.endorsement),
                    onetap: !!a._isTextEmpty(i.data.editGoods.has_one_auction_goods.advance_money),
                    "form.dispatch_price": i.data.editGoods.has_one_auction_goods.dispatch_price,
                    isshowtime1: e.default.formatTimeTwo(i.data.editGoods.has_one_auction_goods.start_shooting, "Y/M/D h:m:s"),
                    isshowtime2: e.default.formatTimeTwo(i.data.editGoods.has_one_auction_goods.end_shooting, "Y/M/D h:m:s")
                })) : wx.showToast({
                    title: i.msg,
                    icon: "none",
                    duration: 1e3
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    showPop: function() {
        var t = this, e = Object.assign(t.data.params_json.from, t.data.form);
        a._isTextEmpty(e.content) || (e.content = '<img src="'.concat(e.content, '" style="width:100%;"><br />'));
        var o = [];
        if (o[0] = JSON.parse(t.data.params_json.category)[0][0], o[1] = JSON.parse(t.data.params_json.category)[0][1], 
        JSON.parse(t.data.params_json.category)[0][2] && (o[2] = JSON.parse(t.data.params_json.category)[0][2]), 
        e.param_title = JSON.parse(t.data.params_json.param_title), e.param_value = JSON.parse(t.data.params_json.param_value), 
        e.category = o, e.thumb_url = JSON.stringify(e.thumb_url), e.art = "releaseGoods", 
        e.start_shooting = String(new Date(e.start_shooting).getTime()).substring(0, 10), 
        e.end_shooting = String(new Date(e.end_shooting).getTime()).substring(0, 10), 2 == e.prepayment_mode ? delete e.advance_proportion : delete e.advance_money, 
        2 == e.em_mode ? delete e.em_proportion : delete e.endorsement, delete e.em_mode, 
        e.start_shooting && "NaN" != e.start_shooting) if (e.end_shooting && "NaN" != e.end_shooting) if (Number(e.start_shooting) >= Number(e.end_shooting)) a.tips("开始时间不能大于结束时间"); else {
            var i = a.getNetAddresss("plugin.auction.api.index.getAuctionData");
            a._postNetWork({
                url: i,
                data: e,
                success: function(e) {
                    var o = e.data;
                    1 == o.result ? (console.log(o), t.data.is_examine && t.setData({
                        show: !0
                    })) : wx.showToast({
                        title: o.msg,
                        icon: "none",
                        duration: 1e3
                    });
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        } else a.tips("请选择结束时间"); else a.tips("请选择开始时间");
    }
});